package chainsMod;

import chainsMod.code.Filter;
import chainsMod.code.Trouble;

// 客户端类
public class Client {

    public static void main(String[] args) {
        code code = new code();
        Filter characterEncodingFilter = code.new CharacterEncodingFilter();
        Filter dataTypeConversionFilter = code.new DataTypeConversionFilter();
        Filter dataValidationFilter = code.new DataValidationFilter();

        // 构建过滤器链，使用链式调用
        characterEncodingFilter.setNext(dataTypeConversionFilter).setNext(dataValidationFilter);

        // 测试用例1：测试字符编码转换过滤器
        Trouble trouble1 = code.new Trouble("CharacterEncoding");
        System.out.println("Testing Character Encoding Filter:");
        characterEncodingFilter.resolve(trouble1);
        System.out.println();

        // 测试用例2：测试数据类型转换过滤器
        Trouble trouble2 = code.new Trouble("DataTypeConversion");
        System.out.println("Testing Data Type Conversion Filter:");
        characterEncodingFilter.resolve(trouble2);
        System.out.println();

        // 测试用例3：测试数据校验过滤器
        Trouble trouble3 = code.new Trouble("DataValidation");
        System.out.println("Testing Data Validation Filter:");
        characterEncodingFilter.resolve(trouble3);

    }
}
